<?php

namespace App\Entity;

use App\Repository\NoticeRepository;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass=NoticeRepository::class)
 * @ORM\Table(options={"comment":"消息表"})
 * @ORM\HasLifecycleCallbacks()
 */
class Notice {
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="integer", options={"comment":"消息类型ID"})
     */
    private $notice_type_id;

    /**
     * @ORM\Column(type="string", length=255, options={"comment":"标题"})
     */
    private $title;

    /**
     * @ORM\Column(type="text", options={"comment":"消息正文"})
     */
    private $content;

    /**
     * @ORM\Column(type="integer", options={"default"="0","comment"="发送方类型 0系统 1用户"})
     */
    private $from_type;

    /**
     * @ORM\Column(type="integer", options={"comment"="发送方对应类型ID"})
     */
    private $from_id;

    /**
     * @ORM\Column(type="integer", options={"default"="0","comment"="接收方类型 0全部 1用户组 2用户"})
     */
    private $to_type;

    /**
     * @ORM\Column(type="json", options={"comment"="接收方对应类型ID集合"})
     */
    private $to_id;

    /**
     * @ORM\Column(type="boolean", options={"default"="1","comment"="状态 0删除 1正常"})
     */
    private $status = true;

    /**
     * @ORM\Column(type="integer", options={"default"="0","comment"="消息创建人ID，0表示系统"})
     */
    private $admin_user_id = 0;

    /**
     * @ORM\Column(type="datetime", nullable=true)
     */
    private $created_at;

    /**
     * @ORM\Column(type="datetime", nullable=true)
     */
    private $updated_at;

    public function getId (): ?int {
        return $this->id;
    }

    public function getNoticeTypeId (): ?int {
        return $this->notice_type_id;
    }

    public function setNoticeTypeId (int $notice_type_id): self {
        $this->notice_type_id = $notice_type_id;

        return $this;
    }

    public function getTitle (): ?string {
        return $this->title;
    }

    public function setTitle (string $title): self {
        $this->title = $title;

        return $this;
    }

    public function getContent (): ?string {
        return $this->content;
    }

    public function setContent (string $content): self {
        $this->content = $content;

        return $this;
    }

    public function getFromType (): ?int {
        return $this->from_type;
    }

    public function setFromType (int $from_type): self {
        $this->from_type = $from_type;

        return $this;
    }

    public function getFromId (): ?int {
        return $this->from_id;
    }

    public function setFromId (int $from_id): self {
        $this->from_id = $from_id;

        return $this;
    }

    public function getToType (): ?int {
        return $this->to_type;
    }

    public function setToType (int $to_type): self {
        $this->to_type = $to_type;

        return $this;
    }

    public function getCreatedAt (): ?\DateTimeInterface {
        return $this->created_at;
    }

    public function setCreatedAt (?\DateTimeInterface $created_at): self {
        $this->created_at = $created_at;

        return $this;
    }

    public function getUpdatedAt (): ?\DateTimeInterface {
        return $this->updated_at;
    }

    public function setUpdatedAt (?\DateTimeInterface $updated_at): self {
        $this->updated_at = $updated_at;

        return $this;
    }

    public function getToId (): ?array {
        return $this->to_id;
    }

    public function setToId (array $to_id): self {
        $this->to_id = $to_id;

        return $this;
    }

    public function getStatus (): ?bool {
        return $this->status;
    }

    public function setStatus (bool $status): self {
        $this->status = $status;

        return $this;
    }

    public function getAdminUserId (): ?int {
        return $this->admin_user_id;
    }

    public function setAdminUserId (int $admin_user_id): self {
        $this->admin_user_id = $admin_user_id;

        return $this;
    }

    /**
     * 新建之前
     * @ORM\PrePersist()
     */
    public function prePersistHook () {
        // 添加创建时间
        $this->created_at = new \DateTime();
    }

    /**
     * 更新之前
     * @ORM\PreUpdate()
     */
    public function preUpdateHook () {
        // 添加更新时间
        $this->updated_at = new \DateTime();
    }
}
